package com.czk.springboot.reactive.reactor.subscribe;

import reactor.core.publisher.Flux;

public class SubscribeDemo1 {
    public static void main(String[] args) {

        Flux<String> flux = Flux.range(0, 5)
                .map(e -> {
                    System.out.println("转换");
                    return e + "czk";
                });
        // 1 流被订阅 ，默认订阅
        flux.subscribe();

        // 2 订阅元素，并按自己处理
        // 转换  0czk 挨个打印---每流一个元素做处理
        flux.subscribe(System.out::println);


        // 3 打印异常
        flux.subscribe(System.out::println, throwable -> {
            System.out.println("throwable===="+throwable);
        });

        // 打印完成的信息
        flux.subscribe(System.out::println, throwable -> {
            System.out.println("throwable===="+throwable);
        },()->System.out.println("完成"));


    }
}
